/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-09-25
 * Time: 21:48
 */





class ListNode {
    int val;
    ListNode next;
    ListNode() {}
    ListNode(int val) { this.val = val; }
    ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}


public class Test {
//    public static boolean test(String str) {
//        return str.toLowerCase() == "admin";
//    }
//    public static void main(String[] args) {
//        System.out.println(Test.test("Admin"));
//    }

    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode phead = new ListNode();
        ListNode s = phead;
        int t = 0;
        while(l1 != null || l2 != null || t != 0) {
            int sum = (l1 == null ? 0 : l1.val) + (l2 == null ? 0 : l2.val);
            ListNode node = new ListNode((sum + t) % 10);
            s.next = node;
            s = s.next;
            t = sum / 10;
            l1 = (l1 == null ? null : l1.next);
            l2 = (l2 == null ? null : l2.next);
        }

        return phead.next;
    }
}

